use axum::routing::{delete, get, put};
use axum::{routing::post, Router};

use crate::bootstrap::AppState;
use crate::controller::user::order;
use crate::controller::user::pay_notify::pay_success_notify;

pub fn user_order_router(state: &AppState) -> Router<AppState> {
    let router = Router::new()
        // 下单
        .route("/submit", post(order::submit))
        // 再来一单
        .route("/repetition/:id", post(order::repetition))
        // 取消订单
        .route("/cancel/:id", put(order::cancel))
        // 订单详情
        .route("/orderDetail/:id", get(order::details))
        // 历史订单
        .route("/historyOrders", get(order::page))
        // 下单
        .route("/default", get(order::submit))
        .route("/payment", put(order::payment))
        // 支付订单
        .route("/pay_success", post(pay_success_notify))
        .route("/list", get(order::payment))
        .with_state(state.clone());

    router
}
